import { EntitySchema } from "typeorm";

// 定义消息实体的接口
export interface Message {
  id: number;
  username: string;
  content: string;
  room: string;
  createdAt: Date;
}

// 使用 EntitySchema 定义实体
export const MessageSchema = new EntitySchema<Message>({
  name: "Message",
  columns: {
    id: {
      type: Number,
      primary: true,
      generated: true,
    },
    username: {
      type: String,
    },
    content: {
      type: String,
    },
    room: {
      type: String,
    },
    createdAt: {
      type: Date,
      createDate: true,
    },
  },
});
